#!/bin/bash

echo "=========================================="
echo "Flask应用诊断脚本"
echo "=========================================="
echo

echo "检查虚拟环境..."
if [ ! -f "venv/bin/activate" ]; then
    echo "错误: 虚拟环境不存在，请先运行 ./install.sh 安装依赖"
    exit 1
fi

echo "激活虚拟环境..."
source venv/bin/activate

echo
echo "检查Flask是否安装..."
python -c "import flask; print('Flask版本:', flask.__version__)"

echo
echo "检查应用文件..."
if [ ! -f "app.py" ]; then
    echo "错误: app.py 文件不存在"
    exit 1
fi

echo
echo "检查路由..."
python -c "
from app import app
print('已注册的路由:')
for rule in app.url_map.iter_rules():
    print('  ', rule)
"

echo
echo "启动Flask应用进行测试..."
echo "请在另一个终端中运行以下命令测试:"
echo "curl http://127.0.0.1:5000/dezhou"
echo
echo "按 Ctrl+C 停止测试"
python app.py
